import {createRouter,createWebHashHistory} from 'vue-router'
import routerPages from './router'
import { getToken } from '@/utils/auth'
const routes = [...routerPages]
const router = createRouter({
    history: createWebHashHistory(),
    routes 
})

// router.beforeEach((to, from, next) => {
//     console.log(localStorage.getItem('userToken'));
//     // 判断有没有登录
//     const token = getToken();
//     console.log(token,'这是路由里面的');
//     if (!token) {
//         if (to.name == "login") {
//             next();
//         } else {
//             router.push('login')
//         }
//     } else {
//         next();
//     }
// });
export default router
